﻿@inject IHttpService _httpService
@inject IDataCacheService _dataCacheService


@if (_dataCacheService.UserPendingDataCatche.Items.Any())
{
    <CnGalWebSite.Components.Containers.MasaTitleContainer Title="待审核的编辑" Icon="fa fa-fw  fa-pencil" Class="mb-4" Outline Collapable>
        <div class="row">
            @foreach (var item in Model.Where(s => s.DisplayMode == UserPendingDataDisplayMode.Main))
            {
                <div class="col-12 col-sm-6 col-md-4 col-lg-3 col-xxl-2 mb-4">
                    <DataCard Model="item" />
                </div>
            }
            <div class="col-12"></div>
            @foreach (var item in Model.Where(s => s.DisplayMode == UserPendingDataDisplayMode.Thum))
            {
                <div class="col-12 col-sm-6 col-md-4 col-lg-3 col-xxl-2 mb-4">
                    <DataCard Model="item" />
                </div>
            }
            <div class="col-12"></div>
            @foreach (var item in Model.Where(s => s.DisplayMode == UserPendingDataDisplayMode.Text))
            {
                <div class="col-12 col-sm-6 col-md-4 mb-4">
                    <DataCard Model="item" />
                </div>
            }
        </div>


        @if (_dataCacheService.UserPendingDataCatche.TotalPages > 1)
        {
            <CnGalWebSite.Components.Paginations.MasaPagination Value="@_dataCacheService.UserPendingDataCatche.CurrentPage" Length="@_dataCacheService.UserPendingDataCatche.TotalPages" ValueChanged="OnPageClick" />
        }

    </CnGalWebSite.Components.Containers.MasaTitleContainer>
}

@code {

    [CascadingParameter]
    public ErrorHandler ErrorHandler { get; set; }

[Parameter]
    public List<UserPendingDataModel> Model { get; set; }

    protected override void OnInitialized()
    {
        OnPageClick(1);
    }

    private void OnPageClick(int pageIndex)
    {
        _dataCacheService.UserPendingDataCatche.CurrentPage = pageIndex;
        Model = _dataCacheService.UserPendingDataCatche.Items.OrderByDescending(s => s.DisplayMode).Skip((_dataCacheService.UserPendingDataCatche.CurrentPage - 1) * _dataCacheService.UserPendingDataCatche.MaxCount).Take(_dataCacheService.UserPendingDataCatche.MaxCount).ToList();

        StateHasChanged();

    }

}
